package com.hxx.widget.richtext.toolbar

import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import com.hxx.widget.R
import com.hxx.widget.loadFromLayoutId

/***
 * 富文本编辑器工具栏
 */
class RichTextToolbar @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
    var onToolMenuItemListener: (Int) -> Unit = {}

    init {
        orientation = HORIZONTAL
        loadFromLayoutId(R.layout.widget_layout_richtext_toolbar)
        for (i in 0 until childCount) {
            val child = getChildAt(i)
            child.setOnClickListener {
                onToolMenuItemListener(i)
            }
        }
    }
}